/**
 * 菜单管理模块
 */
import axios from '@/libs/http'
import qs from 'qs'

/**
 * 获取所有菜单树
 */
export const getAllMenuData = sysCode => {
  return axios({
    method: 'get',
    url: '/auth/menus?sysCode='+sysCode
  })
}

/**
 * 检查菜单标题是否已存在
 */
export const checkTitle = (id,title) => {
  return axios({
    method: 'post',
    url: '/auth/menu/checkTitle',
    data: qs.stringify({id,title})
  })
}

/**
 * 检查菜单路由是否已存在
 */
export const checkName = (id,name) => {
  return axios({
    method: 'post',
    url: '/auth/menu/checkName',
    data: qs.stringify({id,name})
  })
}

/**
 * 更新菜单数据
 */
export const updateMenu = data => {
  return axios({
    method: 'post',
    url: '/auth/menu?action=upd',
    data: data
  })
}

/**
 * 添加菜单
 */
export const addMenu = data => {
  return axios({
    method: 'post',
    url: '/auth/menu?action=add',
    data: data
  })
}

/**
 * 删除菜单
 */
export const deleteMenu = data => {
  return axios({
    method: 'post',
    url: '/auth/menu?action=del',
    data: data
  })
}

/**
 * 获取菜单服务列表
 */
export const menuServices = () => {
  return axios({
    method: 'get',
    url: '/auth/menu/services'
  })
}
